<?php

// [ 会员 ]

namespace app\common\validate;
use think\Validate;

class Member extends Validate
{
    // 规则
    protected $rule = [
        'id'         => 'require|integer',
        'mobile'     => 'require|mobile',
        'nickname'   => 'max:20',
        'headimgurl' => 'max:255',
        'passport'   => 'require|length:4,32',
        'password'   => 'require|length:4,32',
        'cofimpwd'   => 'require|length:4,32|confirm:password',
        'ext'        => 'max:8000',
        'pid'        => 'require|integer',
        'status'     => ['regex'=>'/^(0|1)$/'],
        'code'       => 'require|integer|length:6',
    ];

    // 消息
    protected $message = [
        'id.require'         => '主键必须',
        'id.integer'         => '主键必须是数字',

        'mobile.require'     => '手机号必须',
        'mobile.mobile'      => '手机号格式错误',

        'nickname.max'       => '昵称最大长度为20个字符',
        
        'headimgurl.max'     => '头像最大长度为255个字符',

        'passport.require'   => '原登录密码必须',
        'passport.length'    => '原登录密码只能在4~32个字符之间',

        'password.require'   => '登录密码必须',
        'password.length'    => '登录密码只能在4~32个字符之间',

        'cofimpwd.require'   => '确认登录密码必须',
        'cofimpwd.length'    => '确认登录密码只能在4~32个字符之间',
        'cofimpwd.confirm'   => '确认登录密码与登录密码不一致',
        
        'ext.max'            => '扩展字段最大长度为8000个字符',

        'pid.require'        => 'PID必须',
        'pid.integer'        => 'PID必须是数字',

        'status'             => '状态只能为0|1',

        'code.require'       => '短信码必须',
        'code.integer'       => '短信码必须是数字',
        'code.length'        => '短信码长度为6',
    ];

    // 场景
    protected $scene = [
        // 登录
        'login'   => ['mobile','password'],
        // 注册
        'reg'     => ['mobile','code'],
        // 修改密码
        'upPwd'   => ['passport','password','cofimpwd'],
        // 修改我的信息
        'upUinfo' => ['nickname','headimgurl','ext'],
        // 发送短信码
        'sendCode' => ['mobile'],
    ];
}
